package com.j.lemon.learn.pulsar;

import com.alibaba.fastjson.JSON;
import org.apache.pulsar.client.api.*;

/**
 * @Author lijunjun
 * @Date 2020/9/14 11:25
 * @Description
 */
public class ConsumerShared2 {

    public static void main(String[] args) throws PulsarClientException {
        PulsarClient pulsarClient = PulsarUtils.getClient();
        Consumer<byte[]> sharedConsumer = pulsarClient.newConsumer()
                .subscriptionType(SubscriptionType.Shared)
                .subscriptionName("name2")
                .consumerName("b")
                .topic("persistent://4a/audit/subscriptionType-dev1")
                .subscribe();
        ConsumerStats stats = sharedConsumer.getStats();
        System.out.println(JSON.toJSONString(stats));
//        while (true){
//            Message<byte[]> receive = sharedConsumer.receive();
//            System.out.println("receive message: " + new String(receive.getData()));
//        }


    }
}
